package com.apes.enquiry.enquiry.repository;

import com.apes.enquiry.enquiry.model.Quote;
import com.apes.framework.jpa.repository.CustomRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 类描述：
 *
 * @ClassName QuoteRepository
 * @Description 描述
 * @Author wushilong
 * @Date 2023/3/20 13:41
 * @Version 1.0
 */
public interface QuoteRepository extends CustomRepository<Quote, String> {

    @Query(value = "select a from Quote a where a.enquiryId = :enquiry and a.partyRoleId = :supplier")
    Quote findOneByEnquiryAndSupplier(String enquiry, String supplier);

    @Query(value = "select a from Quote a where a.enquiryId in :enquiryIds")
    List<Quote> findEnquiryIds(List<String> enquiryIds);
    @Query(value = "select a.partyRoleId from Quote a where a.id =:id")
    List<String> findByEnquiryId(String id);

    @Query(value = "select a.* from SP_MAS_QUOTE a where a.ENQUIRY_ID =:id",nativeQuery = true)
    List<Quote> findAllByEnquiryId(String id);

    @Query(value = "select a from Quote a where a.modelId =:modelId")
    Quote findByModelId(String modelId);
}
